﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using _MetalSlug.Form.ScreenSystem;
using _MetalSlug.Form.ScreenSystem.Message;

namespace _MetalSlug.Form.LoadingScreen
{
    public class LoadingScreen:MyScreen
    {
        String Content;
        GifAnimation.GifAnimation ProgressBar;
        public LoadingScreen()
        {
            LoadContent();
            InitialAttribute();
        }

        public override void LoadContent()
        {
            Background = GameUtil.LoadTexture("LoadScreen");
            ProgressBar = GameUtil.LoadGif("loader");
        }


        public override void Update(GameTime gameTime)
        {
            this.Send(TYPE.PLAYGAME, MyMessage.TYPE.LOADING, Content);
            ProgressBar.Update(gameTime.ElapsedGameTime.Ticks);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
            spriteBatch.Draw(ProgressBar.GetTexture(), new Rectangle((int)GameUtil.ScreenSize.X - 50, 440, ProgressBar.Width + 10, ProgressBar.Height + 10), Color.White);
        }

        public override void InitialAttribute()
        {
            TypeOfWindow = TYPE.LOADING;
        }

        public override void Receive(MyScreen SendWindow, MyMessage SendMessage)
        {
            base.Receive(SendWindow, SendMessage);
            if (SendMessage.Content != null)
            {
                Content = SendMessage.Content.ToString();
            }
            else
            {
                Content = String.Empty;
            }
            
        }

    }
}
